{% extends 'user/base.html' %}

{% block title %}
    <title>地址管理</title>
{% endblock %}

{% block content %}
<section class="slice pt-2 bg-surface-secondary">
    <div class="container mt-4 mb-5 pl-6  ">
        <div class="row">
            <div class="col col-md-3 mb-sm-4">
                <div class="col col-md12">
                    <div class="card-header pb-2 list-group-item-info">
                        个人信息
                    </div>
                    <ul class="list-group list-group-flush" id="myList">
                        <li class="list-group-item"><a href="{{ url_for('users.userInfo') }}" class="link-primary">个人资料</a></li>
                        <li class="list-group-item" style="background-color: #cefaff;"><a href="{{ url_for('address.address_management') }}" class="link-primary">地址管理</a></li>
                        <li class="list-group-item"><a href="{{ url_for('user.order_management') }}" class="link-primary">订单管理</a></li>
                        <li class="list-group-item">
                            <a href="{{ url_for('story.upload_story') }}" class="link-primary">上传故事管理</a>
                        </li>
                    </ul>
                    <div class="card-footer pb-2 list-group-item-info">
                        <p></p>
                    </div>
                </div>
            </div>
            <div class="col col-md-8 col-sm-12 ml-2 p-5 resume_box_body">
                <div class="container mt-4 mb-5">
                    <!-- 新增：Flash 消息显示区域 -->
                    <div class="flash-messages">
                        {% with messages = get_flashed_messages(with_categories=true) %}
                            {% if messages %}
                                {% for category, message in messages %}
                                    <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
                                        {{ message }}
                                        <button type="button" class="close" data-bs-dismiss="alert" aria-label="Close">
                                            <span aria-hidden="true">&times;</span>
                                        </button>
                                    </div>
                                {% endfor %}
                            {% endif %}
                        {% endwith %}
                    </div>
                    <h5 class="font-weight-bold border-bottom pb-2">地址管理</h5>
                    <div class="list-group">
                        {% for address in user.addresses %}
                        <div class="list-group-item" style="background-color:#ffffff;">
                            <div class="d-flex justify-content-between align-items-center">
                                <div>
                                    <p class="mb-1"><strong>收件人:</strong> {{ address.recipient_name }}</p>
                                    <p class="mb-1"><strong>电话:</strong> {{ address.phone }}</p>
                                    <p class="mb-1"><strong>地址:</strong> {{ address.address_line }}</p>
                                </div>
                                <div>
                                    <a href="{{ url_for('address.edit_address', address_id=address.id) }}" class="btn btn-warning btn-sm">编辑</a>
                                    <a href="{{ url_for('address.delete_address', address_id=address.id) }}" onclick="return confirm('确定要删除吗？');" class="btn btn-danger btn-sm">删除</a>
                                </div>
                            </div>
                        </div>
                        {% endfor %}
                    </div>
                    <div class="text-center mt-4">
                        <a href="{{ url_for('address.add_address') }}" class="btn btn-primary">添加新地址</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
{% endblock %} 